<template>
  <div class="container">
    <!-- 顶部状态栏 -->
    <div class="header">
      <div>
        <Back />
      </div>
    </div>

    用户信息
    <div class="profile">
      <div class="avatar">
        <img :src="userData.avatar" alt="用户头像">
      </div>
      <h1>{{ userData.nickName }}</h1> <!-- 原nickname改为nickName -->
      <p>{{ userData.account }}</p>
    </div>

    <!-- 支付宝账户信息 -->
    <div class="account-info">
      <div class="info-item">
        <span class="label">账户</span>
        <span class="info-value">{{ userData.userName }}</span> <!-- 原username改为userName -->
      </div>
      <div class="info-item">
        <span class="label">真实姓名</span>
        <span class="info-value">{{ userData.realname }}</span>
        <span class="verified">已实名</span>
      </div>
    </div>

    <!-- 查看更多按钮 -->
    <div class="more-info">
      <button @click="showMore">查看更多</button>
    </div>

    <!-- 记录生活部分 -->
    <div class="life-record">
      <h2>记录我的生活</h2>
      <p>记录更多照片和视频后，将在此处出现</p>
      <!--
      <div class="placeholder">
        <img src="https://via.placeholder.com/300x150" alt="占位图">
      </div>
      -->
    </div>
  </div>
</template>

<script setup>
import { useUserStore } from '@/stores/userStore'
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import Back from '@/components/icons/Back.vue'

const router = useRouter()
const userStore = useUserStore()

// 计算属性确保数据安全访问
const userData = computed(() => ({
  avatar: userStore.user?.avatar || 'https://via.placeholder.com/80',
  nickName: userStore.user?.nickName || '未登录',
  account: userStore.user?.account || '暂无账号信息',
  userName: userStore.user?.userName || '支付宝账户未绑定'
}))



// 安全校验（可选）
if (!userStore.isAuthenticated) {
  router.replace('/login')
}
</script>

<style scoped>
/* 全局样式 */
body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 375px;
  margin: 0 auto;
  background-color: #fff;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 顶部状态栏 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header .time,
.header .battery {
  font-size: 14px;
  color: #666;
}

/* 用户信息 */
.profile {
  text-align: center;
  margin-bottom: 20px;
}

.profile .avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 10px;
}

.profile h1 {
  font-size: 24px;
  margin: 0;
}

.profile p {
  font-size: 16px;
  color: #888;
}

/* 支付宝账户信息 */
.account-info {
  margin-bottom: 20px;
}

.account-info .info-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.account-info .info-item:last-child {
  border-bottom: none;
}

.account-info .label {
  font-size: 14px;
  color: #666;
  min-width: 80px;
  /* 固定标签宽度 */
}

.account-info .info-value {
  flex: 1;
  font-size: 14px;
  color: #333;
  margin-left: 10px;
}

.verified {
  font-size: 12px;
  color: green;
  margin-left: 10px;
}

/* 查看更多按钮 */
.more-info button {
  width: 100%;
  padding: 12px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.more-info button:hover {
  background-color: #0056b3;
}

/* 记录生活部分 */
.life-record {
  text-align: center;
  margin-top: 20px;
}

.life-record h2 {
  font-size: 20px;
  margin: 0 0 10px 0;
}

.life-record p {
  font-size: 14px;
  color: #888;
  margin-bottom: 20px;
}

.life-record .placeholder img {
  width: 100%;
  border-radius: 8px;
}
</style>